home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programmierung
/
Power-Programmierung (Tewi)(1994).iso
/
magazine
/
dbms_mag
/
9107
/
paradox2
< prev
next >
Wrap
Text File
|
1991-05-28
|
5KB
|
141 lines
LISTING 2. A Vertical Menu Proc
1 ; ------------------------------------------------------------
2 ; Display popup menu and allow scrolling
3 ; DBMS - Speaking of PAL - July, 1991 - Listing 2
4 ;
5 ; This procedure displays a vertical bounce-bar menu and allows
6 ; the user to scroll through the list to select a menu choice.
7 ; --------------------------------------------------------------
8 proc VERTICAL_MENU( TOP.ROW, ; row of top left corner
9 TOP.COL, ; column of top left corner
1 MAX.SIZE, ; max width of the longest choice
11 MENU.COLOR, ; color for menu and choices
12 HIGH.COLOR ; color for highlight
13 )
14
15 private HOW.MANY,
16 X
17
18 ; determine the size of the array and set the "current" element
19
20 HOW.MANY = arraysize(CHOICES)
21 WHICH.CHOICE = 1
22 cursor off
23
24 ; display the drop shadow on the canvas
25
26 paintcanvas
27 attribute 7
28 TOP.ROW+1, TOP.COL+2, TOP.ROW+HOW.MANY+2, TOP.COL+MAX.SIZE+5
29
30 ; display the menu box itself
31
32 paintcanvas
33 fill " "
34 attribute MENU.COLOR
35 TOP.ROW, TOP.COL, TOP.ROW+HOW.MANY+1, TOP.COL+MAX.SIZE+3
36
37 ; display the menu border
38
39 paintcanvas
40 border
41 fill "(chr218)" + fill("(chr196)",MAX.SIZE+2) + "(chr191)"
42 + fill("(chr179)",HOW.MANY*2) +
43 "(chr192)" + fill("(chr196)",MAX.SIZE+2) + "(chr217)"
44 attribute MENU.COLOR
45 TOP.ROW, TOP.COL, TOP.ROW+HOW.MANY+1, TOP.COL+MAX.SIZE+3
46
47 ; set the color for subsequent writes to the screen
48
49 style attribute MENU.COLOR
50
51 ; display prompt on top two lines of the screen
52
53 @ 0,0 clear eol ?? "Highlight choice & press [Enter] to select it"
54 @ 1,0 clear eol ?? "Or press [Esc] to return to previous screen"
55
56 ; display the menu choices themselves
57
58 for X from 1 to HOW.MANY
59 @ TOP.ROW+X, TOP.COL+2 ?? CHOICES[X]
60 endfor
61
62 ; keystroke processing loop
63
64 while (true)
65
66 ; highlight the current choice and wait for a keypress
67 ; then change the color back to the "background"
68
69 paintcanvas
70 attribute HIGH.COLOR
71 TOP.ROW+WHICH.CHOICE, TOP.COL+2,
72 TOP.ROW+WHICH.CHOICE, TOP.COL+MAX.SIZE+1
73
74 retval = getchar()
75
76 paintcanvas
77 attribute MENU.COLOR
78 TOP.ROW+WHICH.CHOICE, TOP.COL+2,
79 TOP.ROW+WHICH.CHOICE, TOP.COL+MAX.SIZE+1
80
81 ; process keystrokes, changing the "current" element
82
83 switch
84 case retval = -72 : ; UP
85 if WHICH.CHOICE = 1 then
86 WHICH.CHOICE = HOW.MANY
87 else
88 WHICH.CHOICE = WHICH.CHOICE - 1
89 endif
90
91 case retval = -80 : ; DOWN
92 if WHICH.CHOICE = HOW.MANY then
93 WHICH.CHOICE = 1
94 else
95 WHICH.CHOICE = WHICH.CHOICE + 1
96 endif
97
98 case retval = -71 : ; HOME
99 WHICH.CHOICE = 1
100
101 case retval = -79 : ; END
102 WHICH.CHOICE = HOW.MANY
103
104 case retval = 27 : ; ESC
105 return False
106
107 case retval = 13 : ; ENTER
108 return WHICH.CHOICE
109
110 otherwise :
111 beep
112
113 endswitch
114
115 endwhile
116
117 endproc
118
119 ; ----------------------------------------------------------
120 ; sample code to demonstrate the menu in action
121 ; ----------------------------------------------------------
122
123 array CHOICES[6]
124 CHOICES[1] = "Enter Customers"
125 CHOICES[2] = "Update Order Volumes"
126 CHOICES[3] = "Process Outstanding Invoices"
127 CHOICES[4] = "Generate Summary Reports"
128 CHOICES[5] = "Archive Old Customers"
129 CHOICES[6] = "Graph Customer Credit"
130
131 VERTICAL_MENU( 2, 10, 28, 31, 79 )
132
133 if retval = False then
134 message "You pressed [Esc]"
135 else
136 message "You selected choice ", retval
137 endif
138 sleep 1000